package com.atguigu.eduservice.service.impl;

import com.atguigu.eduservice.entity.EduComment;
import com.atguigu.eduservice.entity.vo.request.EduCommentRequestVo;
import com.atguigu.eduservice.mapper.EduCommentMapper;
import com.atguigu.eduservice.service.EduCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 评论 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-10-03
 */
@Service
public class EduCommentServiceImpl extends ServiceImpl<EduCommentMapper, EduComment> implements EduCommentService {

    @Autowired
    private EduCommentMapper eduCommentMapper;

    //添加评论
    @Override
    public boolean addComment(EduCommentRequestVo.EduCommentAddCommentRequest request) {
        if (!StringUtils.isEmpty(request.getContent())) {
            EduComment eduComment = new EduComment();
            BeanUtils.copyProperties(request, eduComment);
            int insert = eduCommentMapper.insert(eduComment);
            return insert > 0;
        }
        return false;
    }
}
